namespace Peninsula.DataAccess.EF.SqlServer.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _016 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.HouseholdsRestatistics",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 50),
                        TotalDateTime = c.DateTime(),
                        Number = c.Int(nullable: false),
                        TotalPrice = c.Decimal(nullable: false, precision: 18, scale: 2),
                        HouseholdsId = c.String(maxLength: 50),
                        IsDeleted = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false),
                        UpdatedTime = c.DateTime(),
                        UpdatedBy = c.String(nullable: false, maxLength: 50),
                        CreatedBy = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Households", t => t.HouseholdsId)
                .Index(t => t.HouseholdsId);
            
            CreateTable(
                "dbo.MaintenanceStaffRestatistics",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 50),
                        TotalDateTime = c.DateTime(),
                        Number = c.Int(nullable: false),
                        TotalPrice = c.Decimal(nullable: false, precision: 18, scale: 2),
                        MaintenanceStaffId = c.String(maxLength: 50),
                        IsDeleted = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false),
                        UpdatedTime = c.DateTime(),
                        UpdatedBy = c.String(nullable: false, maxLength: 50),
                        CreatedBy = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.MaintenanceStaff", t => t.MaintenanceStaffId)
                .Index(t => t.MaintenanceStaffId);
            
            CreateTable(
                "dbo.StoreRestatistics",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 50),
                        TotalDateTime = c.DateTime(),
                        Number = c.Int(nullable: false),
                        TotalPrice = c.Decimal(nullable: false, precision: 18, scale: 2),
                        StoreId = c.String(maxLength: 50),
                        IsDeleted = c.Boolean(nullable: false),
                        CreatedTime = c.DateTime(nullable: false),
                        UpdatedTime = c.DateTime(),
                        UpdatedBy = c.String(nullable: false, maxLength: 50),
                        CreatedBy = c.String(nullable: false, maxLength: 50),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Store", t => t.StoreId)
                .Index(t => t.StoreId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.StoreRestatistics", "StoreId", "dbo.Store");
            DropForeignKey("dbo.MaintenanceStaffRestatistics", "MaintenanceStaffId", "dbo.MaintenanceStaff");
            DropForeignKey("dbo.HouseholdsRestatistics", "HouseholdsId", "dbo.Households");
            DropIndex("dbo.StoreRestatistics", new[] { "StoreId" });
            DropIndex("dbo.MaintenanceStaffRestatistics", new[] { "MaintenanceStaffId" });
            DropIndex("dbo.HouseholdsRestatistics", new[] { "HouseholdsId" });
            DropTable("dbo.StoreRestatistics");
            DropTable("dbo.MaintenanceStaffRestatistics");
            DropTable("dbo.HouseholdsRestatistics");
        }
    }
}
